home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / gip_02.zip / GIP-SPEC.DOC < prev    next >
Text File  |  1994-12-18  |  38KB  |  835 lines

  1. Graphic Interchange Protocol (GIP) Technical Standards -- Request For Comment
  2. Document #2 release .02
  3.  
  4. New stuff since .01 has a "│" as the first character of the line.
  5.  
  6. The GIP specifications: the developer's viewpoint.
  7.  
  8.  
  9. OVERVIEW
  10.  
  11.   Most of this document is dedicated to the actual protocol used between
  12.   the host and the terminal.  However, there are 4 other major programming
  13.   tasks involved: processing text/file for GIP codes, processing the input
  14.   stream for GIP codes, actually doing the graphics, and working with
  15.   objects.
  16.  
  17.   GIP.ASM is included to make the graphics part easy, and it should be used.
  18.   The parsing jobs depend a lot on how you design your program, and/or how
  19.   it normally handles I/O.  GIP is just like ANSI and Avatar, just add a few
  20.   extra code hooks to your I/O.  Objects are a bit more confusing because
  21.   they are kinda convoluted.  Check out my code in ViewGIP, Commie, and
  22.   Juggernaut for quicky answers.
  23.  
  24.   The protocol is only half the implementation of GIP.  Right now, at least,
  25.   the other half is being able to do the graphics in the same manner I do.
  26.   Example: the protocol defines a box and provides two coordinates, but you
  27.   must also put that box at the proper coordinates (use 0 to N - 1, not 1 to
  28.   N, for example).  The easiest way to test for this compatibility is using
  29.   the .GIP sample files included here, or those from the Juggernaut files.
  30.  
  31.  
  32. COMMANDS
  33.  
  34.   h and v are coordinates.  These go from 0 to N - 1 (N depends on the
  35.   graphics mode).  0,0 is the upper-left corner of the screen.  The
  36.   numbers are integers (0, 1, 2, 3, etc.)   "h" are the cordinates along
  37.   the line (horizontal coordinates), and "v" are the vertical (up/down)
  38.   coordinates.
  39.  
  40.   d is the depth for 3-D, and isn't coded for yet.
  41.  
  42.   The h,v,d values may either represent actual screen coordinates, or
  43.   offsets from the last-used coordinate, command dependent.  When they are
  44.   offset values, negative numbers can be used.  A "0" offset value means to
  45.   draw at least one pixel--since you are drawing from the current pixel to
  46.   pixel location + 0.
  47.  
  48.   n is a number, and its values are also command dependent.
  49.  
  50.   Within each command is text for developers.  This contains the actual
  51.   exchange specification information.  A program that is to send GIP
  52.   standard codes must convert the input stream to this format and send it.
  53.   A program that is to receive GIP standard codes must convert the input
  54.   stream from this to the various GIP actions.
  55.  
  56.   Also as part of the developers information section is what EACH SIDE is
  57.   expected to do.  For the most part, both the sending and receiving side
  58.   do all things listed.
  59.  
  60.   The GIP codes (such as "S2;") are not sent (exchanged) between the BBS
  61.   and comm program in the form which they are read in.  The main difference
  62.   being that the numbers are converted.  So that instead of sending "123" as
  63.   "1", "2", "3", we convert it to an integer and send the two-byte integer
  64.   instead.  This offers a slight throughput advantage, but also makes the
  65.   code writing on the comm program's end much easier.
  66.  
  67.   Sending side: when you do things is up to you.  Example: you can change
  68.   to the color before sending the "Cn;" code, or after sending it.
  69.  
  70.   Notation: <x> when "x" is an ASCII number in byte (8 bit) form.
  71.             [x] when "x" is a REAL number in integer (16 bit) form.
  72.             {x} when "x" is something more complex.
  73.             [[x]] when "x" is LONG number (32 bit).
  74.  
  75.   Variables you will need to maintain:  color, pattern, currentH, currentV,
  76.                                         currentD, objects, patternshift
  77.  
  78.   Examples:
  79.  
  80.     "Sn;"      is exchanged as "<19><83><byte>"  where "<byte>" contains
  81.                 the value of "n".
  82.  
  83.     "Mh,v,d;"  is exchanged as "<19><77><int><int><int>" where the three
  84.                 "<int>"'s contain the values of "h", "v", and "d" in that
  85.                 order.
  86.  
  87.   Notice that the "" (ASCII 19) and the "S" and "M" are sent.  Then the
  88.   numbers are converted and sent.  The comma's and semi-colons are not
  89.   sent.  The numbers are NOT sent as a series of ASCII characters, but
  90.   converted to byte or 2-byte integer form and then sent as a byte or
  91.   two bytes.  The case of the "S" or "M" is significant.
  92.  
  93.   NOTE: For now, "d" is always 0.
  94.  
  95.   For the most part error checking need not be done (for example: if a box 
  96.   command orders a box outside valid range).  Although DOS does handle these
  97.   pretty well, the fact is that an MNP modem for error correction is pretty
  98.   necessary when using this, and that if a sysop designs a menu that will fail
  99.   then they need to correct it to have users using it.
  100.  
  101.   If the specs look like there is lots of oportunity for failure, that's
  102.   because that's the way it was designed.  Selected for speed rather than
  103.   reliability.  The logic: most people have MNP modems, and most sysops won't
  104.   design GIP menus/text that cause their users to get stuck with a bad GIP
  105.   code.  This philosophy is continued in the lack of any way for a user to
  106.   abort a GIP command in the middle (except through modem time-out).  But if
  107.   people really do have problems, or there is a need, I will re-write the
  108.   specs to allow for more error-handling (although, frankly, the error
  109.   handling would look very much like MNP which is why I didn't do it now).
  110.  
  111.  
  112.   COMMAND   DESCRIPTION
  113.  
  114.   Sn;       Switch to graphics mode n.
  115.  
  116.             Where n is:  0 for standard 80x25 mode.
  117.                          1 for 320x200x4 CGA (testing mode only).
  118.                          2 for 640x480x16 VGA.
  119.                          3 for 320x200x256 VGA.
  120.                          4 for 640x480x256 SVGA.
  121.                          5 for 800x600x256 SVGA.
  122.  
  123.             Example:  S2;
  124.                       Begins graphic mode 2.
  125.                       S0;
  126.                       Returns back to normal (ANSI) mode.
  127.  
  128.             Modes 4 and 5 require an SVGA card, and are a bit less-automatic
  129.             for beginner users.  For general-audience graphics, you should
  130.             stick with modes 2 and 3.
  131.  
  132.             Mode 2 provides for 80x60x16 text.  While Mode 4 only provides
  133.             for 40x25x256 text.
  134.  
  135.             For normal operations, mode 2 is the only real practical mode.
  136.             It's drawback is that some sysops might find it's text a little
  137.             small.  This will be solved for in the future when I add support
  138.             for more fonts.
  139.  
  140. │           When this command is used, the current h,v,d positional values
  141. │           should be reset to 0.  Thus, it can be interpreted as a standard
  142. │           clear-screen and go-to-top-of-screen order.  Like ANSI's "[2J" or
  143. │           DOS's CLS.  Similarly, you should set the color to Bright White
  144. │           (C15).  Finally, the pattern should be reset to a solid line.
  145.  
  146. │           GIP (ASCII 19) commands should be ignored unless already in 
  147. │           graphics mode.  So an Sn; command will precede all.
  148.  
  149.  
  150.             BBS/HOST PROGRAM                 │ TERMINAL/COMMUNCATIONS PROGRAM
  151.                                              │
  152.             Obtain "Sn;".                   │
  153.                                              │
  154.             IF n > 255 then don't process.   │
  155.                                              │
  156.             Send "<19><83><n>".              │ Receive "<19><83><n>".
  157.                                              │
  158.             If the bbs/host system can       │ If the system can handle the
  159.             handle the screen mode, then     │ screen mode, then change to
  160.             change to that mode.             │ that mode.
  161.                                              │
  162.             Reset your line-pattern          │ Reset your line-pattern
  163.             variable to solid (-1 or 65534). │ variable to solid (-1 or 65534).
  164.             Reset your pattern shift         │ Reset your pattern shift
  165.             variable to 0.                   │ variable to 0.
  166.  
  167.             EXAMPLE: "S2;" is sent (and received) as "<19><83><2>"
  168.                      (3 bytes).
  169.  
  170.             NOTE: We just change the line-pattern variable here, because there
  171.                   is nothing to draw/display.  The drawing commands should have
  172.                   a parameter for line-pattern-to-use.
  173.                   If the mode cannot be handled, then use 0--it's safer then
  174.                   trying to squeeze higher resolution graphics into lower 
  175.                   modes.
  176.  
  177.  
  178.   Cn;       Switch to color n.
  179.  
  180.             Where n is:  0 to 15
  181.                          0 to 255
  182.  
  183.             Example:  C0;
  184.                       Change the current color to black.
  185.  
  186.             This depends on what mode you are in (either 16 or 256 colors).
  187.             The 16 color mode follows the same color scheme as ANSI does.
  188.  
  189.  
  190.             BBS/HOST PROGRAM                 │ TERMINAL/COMMUNCATIONS PROGRAM
  191.                                              │
  192.             Obtain "Cn;".                   │
  193.                                              │
  194.             IF n > 255 then don't process.   │
  195.                                              │
  196.             Send "<19><67><n>".              │ Receive "<19><67><n>".
  197.                                              │
  198.             Set your color variable to this  │ Set your color variable to this
  199.             value.                           │ value.
  200.  
  201.             EXAMPLE: "C64;" is sent (and received) as "<19><83><64>"
  202.                      (3 bytes).
  203.  
  204.             NOTE: DOS properly handles out-of-range values (eg. 16-255 in a
  205.                   16 color mode) by "wrapping" to the first color and starting
  206.                   again the counter.
  207.                   We just change a variable here, because there is nothing to
  208.                   draw/display.  The drawing commands should have a parameter
  209.                   for pixel color to use.
  210.  
  211.  
  212.   Pn,s;     Set the "pattern" to use for drawing lines and filling boxes.
  213.  
  214.             Where n is:  0 to 65534
  215.                          -1 to 32767
  216.                          A 16 character pattern of 0's and 1's (example:
  217.                          0000111100001111).
  218.  
  219.             Where s is:  -15 to 15
  220.  
  221.             Example:  P1,0;
  222.                       or
  223.                       P0000000000000001,0;
  224.                       will use "               ∙" (15 blanks and then a
  225.                       dot) for the pattern for drawing lines, boxes, etc.
  226.  
  227.             The pattern is the same as formed by the ON/OFF bits of the
  228.             number n, with an ON bit being a visible pixel, and an OFF
  229.             bit being a skipped pixel.
  230.  
  231.             An exception is zero, this is changed to "-1" or "65534" and is
  232.             equivalent to a solid line of pixels.  I did this to make it
  233.             easier to work with, and because "all pixels off" lines aren't
  234.             likely to be needed.
  235.  
  236.             The default is a solid line, and this default is selected each
  237.             time you change the screen mode.  Otherwise the pattern defined
  238.             stays in effect until you do a new pattern-change or another
  239.             screen mode change.
  240.  
  241.             At the start of each line drawing order, we begin with the left-
  242.             most pixel, and continue on through to the right.  Starting again
  243.             at the left after the 16th pixel.
  244.  
  245.             The exception to this is filled boxes.  In order to avoid 
  246.             streaking lines, we incorpate "s"--the shift value.  After each
  247.             line when drawing a filled box, the bit pattern will be shifted
  248.             according to s.  A negative value means to rotate left, a
  249.             positive value means to rotate right, a zero means no shifting.
  250.  
  251.             For example, for the "on-off-on-off" pattern, no shifting would
  252.             yield not a pattern, but an organized set of vertical lines.  If
  253.             you shift more than one, you get organized slanted lines.  So the
  254.             shift you use depends on that pattern you use, and will probably
  255.             require a little trial and error.
  256.  
  257.  
  258.             BBS/HOST PROGRAM                 │ TERMINAL/COMMUNCATIONS PROGRAM
  259.                                              │
  260.             Obtain "Pn,s;".                 │
  261.                                              │
  262.             If n = 0 then set n = -1.        │
  263.                                              │
  264.             Send "<19><80>[n][s]".           │ Receive "<19><80>[n][s]".
  265.                                              │
  266.                                              │ If n = 0 then set n = -1.
  267.                                              │
  268.             Set your pattern variable to     │ Set your pattern variable to
  269.             this n value.                    │ this n value.
  270.             Set your shiftingvariable to     │ Set your shifting variable to
  271.             this s value.                    │ this s value.
  272.  
  273.             EXAMPLE: "P64,-1;" is sent (and received) as "<19><80>[64][-1]"
  274.                      (6 bytes).
  275.  
  276.             NOTE: We just change a variable here, because there is nothing to
  277.                   draw/display.  The drawing commands should have a parameter
  278.                   for pattern to use.
  279.                   In a bit of "reverse logic" if the value of n is 0, you
  280.                   should use instead -1 or 65534--that is, a filled pattern
  281.                   for solid lines.  The reasoning: a blank pattern won't be
  282.                   needed, so lets not confuse ourselves with -1 or 65534 and
  283.                   just use "P0,0;" to reset to solid lines.
  284.                   The pattern shifting value only needs to be used when
  285.                   drawing filled boxes--you do a bitshift in the specified
  286.                   direction after drawing each line.
  287.  
  288.  
  289.   Gh,v,d;   Go to point h,v,d.
  290.  
  291.             Example:  G10,10,0;
  292.                       will move to graphics location 10,10.
  293.  
  294.             Nothing is displayed.
  295.  
  296.             h,v,d cannot be negative numbers.
  297.  
  298.             This is the most used command, as it's used to place lines,
  299.             boxes, and text.
  300.  
  301.  
  302.             BBS/HOST PROGRAM                 │ TERMINAL/COMMUNCATIONS PROGRAM
  303.                                              │
  304.             Obtain "Gh,v,d;".               │
  305.                                              │
  306.             IF h, v, or d, is < 0 then don't │
  307.             process.                         │
  308.                                              │
  309.             Send "<19><71>[h][v][d]".        │ Receive "<19><71>[h][v][d]".
  310.                                              │
  311.             Set your internal location-at    │ Set your internal location-at
  312.             variables to these three values. │ variables to these three values.
  313.  
  314.             EXAMPLE: "G100,200,0;" is sent (and received) as
  315.                      "<19><71>[100][200][0]" (8 bytes).
  316.  
  317.             NOTE: We just change variables here, because there is nothing to
  318.                   draw/display.  The drawing commands should have parameters
  319.                   for h,v,d coordinates to start at.
  320.  
  321.  
  322.   Mh,v,d;   Go to offset point h,v,d.
  323.  
  324.             Example:  G20,20,0;
  325.                       will move from the current location to offset 20,20.
  326.                       After the call, the new current location is 10,10 +
  327.                       the h,v offset (30,30).
  328.  
  329.             Nothing is displayed.
  330.  
  331.             This command is usually only used when defining objects, which
  332.             by their nature can't be screen coordinate dependant.
  333.  
  334.  
  335.             BBS/HOST PROGRAM                 │ TERMINAL/COMMUNCATIONS PROGRAM
  336.                                              │
  337.             Obtain "Mh,v,d;".               │
  338.                                              │
  339.             Send "<19><77>[h][v][d]".        │ Receive "<19><77>[h][v][d]".
  340.                                              │
  341.             Set your internal location-at    │ Set your internal location-at
  342.             variables by adding these values │ variables by adding these values
  343.             to them.                         │ to them.
  344.  
  345.             EXAMPLE: "M100,-50,0;" is sent (and received) as
  346.                      "<19><77>[100][-50][0]" (8 bytes).
  347.  
  348.             NOTE: We just change variables here, because there is nothing to
  349.                   draw/display.  The drawing commands should have parameters
  350.                   for h,v,d coordinates to start at.
  351.  
  352.  
  353.   Lh,v,d;   Draw a line from current point to h,v,d.
  354.  
  355.             Example:  L20,20,0;
  356.                       will draw a line, in the current color, from the
  357.                       current location to offset 20,20.  After the call,
  358.                       the new current location is 10,10 + the h,v offset.
  359.  
  360.             There is no "draw a point" command.  To draw points, use very
  361.             short lines.
  362.  
  363.  
  364.             BBS/HOST PROGRAM                 │ TERMINAL/COMMUNCATIONS PROGRAM
  365.                                              │
  366.             Obtain "Lh,v,d;".               │
  367.                                              │
  368.             Send "<19><76>[h][v][d]".        │ Receive "<19><76>[h][v][d]".
  369.                                              │
  370.             Set your internal location-at    │ Set your internal location-at
  371.             variables by adding these values │ variables by adding these values
  372.             to them.                         │ to them.
  373.                                              │
  374.             Draw a line from your old        │ Draw a line from your old
  375.             location-at variables to your    │ location-at variables to your
  376.             new location-at variables using  │ new location-at variables using
  377.             your color variable and your     │ your color variable and your
  378.             pattern variable.                │ pattern variable.
  379.  
  380.             EXAMPLE: "L100,-50,0;" is sent (and received) as
  381.                      "<19><76>[100][-50][0]" (8 bytes).
  382.  
  383.  
  384.   Bh,v,d;   Draw a rectangle from the current postition to h,v,d.  Where
  385.             h,v,d is the opposite corner of the rectangle.
  386.  
  387.             Example:  B20,20,0;
  388.                       will draw a line-box, in the current color, from the
  389.                       current location to offset 20,20.  After the call
  390. │                     the current location is still 20,20,0.
  391.  
  392.             The current pattern is also used--since the box is usually
  393.             drawn as four lines.
  394.  
  395.  
  396.             BBS/HOST PROGRAM                 │ TERMINAL/COMMUNCATIONS PROGRAM
  397.                                              │
  398.             Obtain "Bh,v,d;".               │
  399.                                              │
  400.             Send "<19><66>[h][v][d]".        │ Receive "<19><66>[h][v][d]".
  401.                                              │
  402. │           Draw a box from your current     │ Draw a box from your current
  403. │           location-at variables to         │ location-at variables to
  404. │           location-at + these values using │ location-at + these values using
  405. │           your color variable and your     │ your color variable and your
  406. │           pattern variable.                │ pattern variable.
  407.  
  408.             EXAMPLE: "B100,-50,0;" is sent (and received) as
  409.                      "<19><66>[100][-50][0]" (8 bytes).
  410.  
  411.  
  412.   Fh,v,d;   Draw a filled/solid rectangle from the current postition to
  413.             corner h,v,d.  Where h,v,d is the opposite corner of the rectangle.
  414.  
  415.             Example:  F20,20,0;
  416.                       will draw a filled box, in the current color, from the
  417.                       current location to offset 20,20.  After the call,
  418. │                     the current location is still 20,20,0.
  419.  
  420.             The current pattern is also used.
  421.  
  422.             If you're trying to draw a box over text, and you get "ghosting"
  423.             of the previous stuff in that area--that's a sure sign that you
  424.             forgot to reset your pattern to solid--that "ghosting" is pixels
  425.             being skipped due to the pattern.
  426.  
  427.             There is no hard rules on how to program for this.  I use a hack
  428.             of just drawing lines to form the box, and after each line 
  429.             rotating the bitmask of the pattern left 1 bit.  This provides
  430.             me with more of a dither look rather than the horizontal lines
  431.             this method would usually generate.
  432.  
  433.  
  434.             BBS/HOST PROGRAM                 │ TERMINAL/COMMUNCATIONS PROGRAM
  435.                                              │
  436.             Obtain "Fh,v,d;".               │
  437.                                              │
  438.             Send "<19><70>[h][v][d]".        │ Receive "<19><70>[h][v][d]".
  439.                                              │
  440. │           Draw a solid box from your       │ Draw a solid box from your
  441. │           current location-at variables to │ current location-at variables to
  442. │           location-at + these values using │ location-at + these values using
  443. │           your color variable and your     │ your color variable and your
  444. │           pattern variable.                │ pattern variable.
  445.  
  446.             EXAMPLE: "F100,-50,0;" is sent (and received) as
  447.                      "<19><70>[100][-50][0]" (8 bytes).
  448.  
  449.  
  450.   fPATHNAME;
  451.             The file exchange protocol.  The heart of GIP.  It is used to
  452.             send any files.  Including .GIF's, .ICO's, .MOD's, .VOC's, etc.
  453.             The software determines what to do with your file based on the
  454.             file's extension.  So if it's a GIF, use .GIF display, etc.
  455.  
  456.             Example:  fC:\BBS\NCD.ICO;
  457.                       would display C:\BBS\NCD.ICO with it's upper-left
  458.                       corner starting at the current location.
  459.                       fC:\BBS\METAL.VOC;
  460.                       would play C:\BBS\METAL.VOC.
  461.  
  462.             It's really an "update protocol"--since the file will not be
  463.             sent if the current version of the file already exists on the
  464.             callers disk in his "your BBS identifier" directory.
  465.  
  466.             The path is not sent, only the filename.
  467.  
  468.             The current coordinates are not changed.
  469.  
  470.             In general, it works as such:
  471.                Send Header with CRC.
  472.                ACK receipt of header.
  473.                If file is new/updated, then ENQ for a new file, else ACK that
  474.                we already have it and it shouldn't be re-sent.
  475.  
  476.  
  477.             BBS/HOST PROGRAM                 │ TERMINAL/COMMUNCATIONS PROGRAM
  478.                                              │
  479.             Obtain "fpathname;".            │
  480.                                              │
  481.             IF pathname not found, then      │
  482.             don't process.                   │
  483.                                              │
  484.             Send "<19><102>"                 │ Receive "<19><102>".
  485.                                              │
  486.             Create variable x to contain:    │
  487.                8 bytes, the GIP ID.          │
  488.               12 bytes, the filename in      │
  489.                  "file.ext    " form.        │
  490.                4 byte LONG, the file's size. │
  491.                2 byte INTEGER, the file's    │
  492.                  time.                       │
  493.                2 byte INTEGER, the file's    │
  494.                  date.                       │
  495.                                              │
  496.             Then we calculate a 16 bit CRC   │
  497.             (xmodem/etc. standard) of x, call│
  498.             it c.                            │
  499.                                              │
  500.  
  501.             Example: for "TESTER.ZIP   1,100,959  10:00:00  5/1/93",
  502.                      and the BBS's GIP ID is "STARCH",
  503.                      we send:
  504.                      "STARCH  TESTER.ZIP  [[size]][time][date]"
  505.  
  506.          1. Send "{x}[c]"                    │ Receive "{x}[c]"
  507.                                              │
  508.             Loop until receive "<5>" or      │ If c is not the CRC of x,
  509.             "<6>".                           │ then send "<5>" and goto 1.
  510.                                              │
  511.             If receive "<5>" then goto 1.    │
  512.                                              │
  513.                                              │ Send "<6>" and goto 2.
  514.                                              │
  515.             If receive "<6>" then goto 2.    │
  516.                                              │
  517.  
  518.             NOTE: I designed my code to give up and exit after 5 tries or if
  519.                   the console had <esc> hit.  Each try occuring if time-out
  520.                   or "resend" (ASCII 5) received.  Time-out can be your
  521.                   choosing, 2-5 seconds probably best, but I use the fossil's
  522.                   own 30 second time-out.
  523.  
  524.  
  525.          2. Loop until receive "<5>" or      │ Compare the file's name, date,
  526.             "<6>".                           │ and size with what's on-line
  527.                                              │ in directory "GIP ID".
  528.                                              │
  529.                                              │ If match, send "<6>" goto 3.
  530.             If receive "<6>" then goto 3.    │
  531.                                              │ Send "<5>".
  532.                                              │
  533.             Send "{x}" where x is the        │ Receive the file's contents
  534.             contents of the file.  Only the  │ into the specified filename in
  535.             mere beginnings of a protocol    │ the "GIP ID" directory.  We
  536.             here: We send 1024 byte blocks   │ receive the file's size's worth
  537.             followed by a delay in which we  │ of bytes.  This is done by
  538.             wait for the other guy to send   │ receiving 1024 bytes, writing
  539.             a character.  The final block    │ it to a file, and then sending
  540.             can be less than 1024 bytes.     │ back a "<6>", and repeating.
  541.                                              │
  542.                                              │ Give the file the time and date
  543.                                              │ that we passed earlier.
  544.  
  545.             NOTE: Example: a file of size 2050 bytes:
  546.                   Sender:                     Receiver:
  547.                   send first 1024 bytes
  548.                                               receive first 1024 bytes
  549.                                               send "<6>"
  550.                   receive "<6>"
  551.                   send second 1024 bytes
  552.                                               receive second 1024 bytes
  553.                                               send "<6>"
  554.                   receive "<6>"
  555.                   send last 2 bytes
  556.                                               receive last 2 bytes
  557.                                               send "<6>"
  558.                   receive "<6>"
  559.  
  560.                   The 1024 and waiting for ACK is done so we don't overflow
  561. │                 buffers and lose characters. [might drop this in the
  562. │                 future as unnecessary]
  563.  
  564.         3.  Display the file.                │ Display the file.
  565.  
  566.             NOTE: "Display the file." for now merely means:
  567.                   "If extension is .ICO, then call up show icon routine and
  568.                   display this icon file."  These are "standard" 766 byte
  569.                   sized 16-color icon files.
  570.                   Thus, for now only .ICO files are supported.  More graphic
  571.                   formats will be added in the future.
  572.                   Any other format should be displayed as a normal text/ansi
  573.                   file of any size.
  574.                   Except for .BMP--the trouble is that right now the only
  575.                   BMP displayer I has displays the colors slightly off.
  576.  
  577.   
  578.   On;~xxx~  Define an object for later display.
  579.  
  580.             Where n is:  0 to 255
  581.  
  582.             Example:  O1;~C3;G5,5,0;L15,5,0;L15,15,0;L5,15,0;L5,5,0;~
  583.                       Which defines Object #1 to be orders to: change to
  584.                       color 3 and goto 5,5 and draw a box.
  585.  
  586.             It's very flexible, you can have GIP codes and normal text
  587.             intermixed.
  588.  
  589.             It's not displayed at the time you define/send it.
  590.  
  591.             Only three restrictions:  no GIP "f<pathname>" commands nor other
  592.             object commands (either defining or using) should be inside the
  593.             two "~" characters.  And, of course, no "~" allowed inside the
  594.             definition.
  595.  
  596.             This is the cyberspace command, with which we will have
  597.             cyberspace in the future.
  598.  
  599.             When defining objects, the maximum size of any one object is
  600.             2048 bytes, and the size of all objects must not exceed 8192
  601.             bytes.  If you need to exceed these limits, I recommend using
  602.             either an icon or graphic image file.
  603.  
  604.  
  605.             BBS/HOST PROGRAM                 │ TERMINAL/COMMUNCATIONS PROGRAM
  606.                                              │
  607.             Obtain "On;~xxx~".              │
  608.                                              │
  609.             IF n > 255 then don't process.   │
  610.                                              │
  611.             Store "xxx" in objects-variable  │
  612.             number n.                        │
  613.                                              │
  614.             Send "<19><79>[n][z]xxx".        │ Receive "<19><79>[n][z]".
  615.             Where z is the length of "xxx".  │
  616.                                              │ IF n > 255 then don't process.
  617.                                              │
  618.                                              │ Receive "xxx" for length z.
  619.                                              │
  620.                                              │ Store "xxx" in objects-variable
  621.                                              │ number n.
  622.  
  623.             EXAMPLE: "O64;~hi there~" is sent (and received) as
  624.                      "<19><79>[64][8]hi there" (14 bytes).
  625.  
  626.             NOTE: Nothing is shown/displayed.
  627.                   If there are GIP codes in the "xxx" then these are not
  628.                   converted to anything (just yet).  Thus "C2;HiC3;there"
  629.                   stays in this form when stored to the object variable.
  630.  
  631.  
  632.   on;       Call up and display/use an Object.
  633.  
  634.             Where n is:  0 to 255
  635.  
  636.             Example:  o1;
  637.                       Will display Object #1 we defined earlier.
  638.  
  639.             This offers fast graphics, since the commands do not have to
  640.             be re-sent each time you want to display the same thing.
  641.             It also offers the sysop convience.  When testing postioning
  642.             of GIP drawings, and when working with lots of the same
  643.             drawings.
  644.  
  645.  
  646.             BBS/HOST PROGRAM                 │ TERMINAL/COMMUNCATIONS PROGRAM
  647.                                              │
  648.             Obtain "on;".                   │
  649.                                              │
  650.             IF n > 255 then don't process.   │
  651.                                              │
  652.             Send "<19><111><n>".             │ Receive "<19><111><n>".
  653.                                              │
  654.                                              │ IF n > 255 then don't process.
  655.                                              │
  656.             Process the data stored in       │ Process the data stored in
  657.             object n's variable.             │ object n's variable.
  658.             For GIP codes, we convert and    │ For GIP codes, we need a minor
  659.             process as normal, but don't     │ BBS-like parser to convert them
  660.             send them out the port.          │ to usable form.
  661.  
  662.             EXAMPLE: "o2;" is sent (and received) as "<19><111><2>"
  663.                      (3 bytes).
  664.  
  665.             NOTE: Processing GIP codes from Terminal side is not as hard as
  666.                   it may first seem (see example source code).
  667.  
  668.  
  669. ASCII TEXT
  670.  
  671.   Text is like lines--its pixels are drawn on top of whatever is there
  672.   already.  It uses whatever was the last defined color, at whatever was
  673.   the last location.
  674.  
  675.   For now, only an 8x8 font is used.  After each character is displayed,
  676.   we automatically add 8 to the orginal (pre-drawing) horizontal location,
  677.   which has the effect of putting us right where the next character would
  678.   be drawn.
  679.  
  680.   For spans of spaces, 8 or fewer spaces is more efficient than using a
  681.   "Gh,v,d;" command to move you ahead.
  682.  
  683.   For CR/LF's, we simply change the horizontal coordinate to zero, and add
  684.   8 to the vertical coordinate.  This allows us to display normal text going
  685.   down the screen normally.  However, there are problems when you reach the
  686.   end of the screen--as the there no scrolling in GIP (nor any wraparound to
  687.   the next lines).  Think of CR/LF's this way: just another cursor positioning
  688.   command: "go to start of next line".
  689.  
  690.   Usually the effects of CR/LF's do not matter.  They are very useful for
  691.   making GIP files readable.  So don't be afraid to use them for that purpose.
  692.  
  693.   The full 256 character ASCII set may be sent and displayed except for the
  694.   following codes: 10, 13, 19, 12, 22, 25, 27
  695.   These codes are used by ANSI, GIP, Avatar, and text to signify something
  696.   besides their normal ASCII character.
  697.  
  698.  
  699. EXAMPLES
  700.  
  701.   "S2;fC:\BBS\NODE001\GRA\PIC1.ICO;G300,300,0;Hi there!"
  702.  
  703.   will: clear the screen and go to graphics mode (S2;)
  704.         send the file PIC1.ICO (if the caller doesn't have it already)
  705.           (fC:\BBS\NODE001\GRA\PIC1.ICO;)
  706.         locate pixel 300,300 (G300,300,0;)
  707.         and display "Hi there!" at that point (normal ASCII text)
  708.  
  709.   "S2;G300,300,0;fC:\BBS\NODE001\GRA\PIC1.ICO;Hi there!"
  710.  
  711.   will: same as the above, but draws the icon at 300,300 and "Hi there!"
  712.         right after the icon.
  713.  
  714.  
  715. NOTES
  716.  
  717.   GIP codes, like ANSI, can be put into files and displayed.  I recommend
  718.   the extension .GIP (like .ANS) but it's not required.
  719.  
  720.   GIP contains no error-checking stuff, and so should only be used by MNP
  721.   modems (the baud doesn't matter).
  722.  
  723.   Before shelling to dos (or exiting the program) you should reset the 
  724.   graphics mode to normal 80x25 ANSI.
  725.  
  726.  
  727. CONVERTING TEXT FILES TO GIP
  728.  
  729.   For bare bones conversion of a standard text file to gip, there are only
  730.   two things to do:
  731.  
  732.     Add a "Sn;Cn;" at the start of the file.
  733.     Add a "S0;" at the end of the file.
  734.  
  735.  
  736. CONVERTING ANSI FILES TO GIP
  737.  
  738.   These are the steps to follow that to make conversi of ANSI's easier:
  739.  
  740.   First, convert the "[xC" "cursor jumping" commands to their spaces 
  741.   equivalent.  Example "[7C" becomes "       ".  You can optimize it with 
  742.   "Gh,v,d;" commands later.  A "Gh,v,d;" command uses 8 characters in it's 
  743.   transmission, so there is nothing to be gained by reducing gaps 8 or fewer 
  744.   characters to "Gh,v,d;" calls.
  745.  
  746.   Second, convert the "[x,y,zm" color commands.  Easy except for background 
  747.   commands "[44m"--in which case you'll probably want to first draw a filled
  748.   box of the length desired and then draw the characters on top of it.
  749.  
  750.   The above stuff on converting normal text files is useful too.
  751.  
  752.   0,8,16,24 etc. correspond to normal 80x25 text columns.
  753.  
  754.  
  755. VIEWGIP
  756.  
  757.   Also enclosed is VIEWGIP.EXE.
  758.  
  759.   ViewGIP will let you display files with GIP codes inside them.  It works
  760.   much like TYPE filename.ANS works.  Just type: VIEWGIP filename.GIP
  761.  
  762.   The only limitations are that the two SVGA modes won't work with this
  763.   viewer, and the maximum file size is 16k.
  764.  
  765.   The program will display the file, and then wait for you to hit a key.
  766.   For best viewing, I recommend you remove any "S0;" mode-to-normal you
  767.   have at the end of the file before displaying.
  768.  
  769.   The source code for ViewGIP is VIEWGIP.BAS.  Like all the included
  770.   source code, it both uses the GIP.ASM graphic routines, and makes use
  771.   of some of my assembly routines from Juggernaut (not included).
  772.  
  773.  
  774. COMMIE
  775.  
  776.   Commie is available in a separate archive.  Your users can use this
  777.   program to see your GIP graphics.
  778.  
  779.   The source code to Commie is COMMIE.BAS.  For those interested in
  780.   adding GIP ability to their communications program, this will be
  781.   invaluable.  For those interested in adding it to BBS programs, you
  782.   should get the Juggernaut program and take a look at it.
  783.  
  784.  
  785. CONCLUSION
  786.  
  787.   All of the above stuff is already coded and done.  The only supported file
  788. │ display format right now is ".ICO" for icons, and .BMP for images--and I'm
  789. │ looking for source code to display ANY other graphic formats.
  790.  
  791.   The stuff below still needs to be done, and will be available sometime in
  792.   the future:
  793.  
  794.     d coordinates (depth/3-D stuff)
  795.     GIFs/TIFs/PCXs/BMPs
  796.     sound files (VOC/MOD)
  797.     fonts (TrueType preferred)
  798.     circle's/elipses
  799.     etc.
  800.  
  801.   This is a very open-ended standard.  It's success and power depend on other
  802.   people supplying code for many of the things not done.  For instance, I
  803.   don't know 3-D graphics programming, the drivers for sound cards, or how to
  804.   display the various image file formats.  I'll teach myself and get it, but
  805.   reinventing wheels is not efficient.  So feel free to help.
  806.  
  807.  
  808.  
  809. I can be reached for comment/suggestions at:
  810.  
  811.     Immortality
  812.     414-643-1576
  813.     24 hrs.
  814.  
  815. Either log in, or just dump your NetMail on me.
  816.  
  817. John Rohner
  818. January 1994
  819.  
  820.  
  821.  
  822. I hereby release the GIP specifications, and any code specific only to 
  823. implementing the GIP specifications I include as an example, to the Public
  824. Domain for full, free, and uncredited distribution by other GIP-capable
  825. program authors. 
  826.  
  827. With the premediated hope that authors will simply import the code into their
  828. program to provide GIP support.  With a promise to never challenge nor
  829. discredit said authors, and that this Public Domain declaration shall be
  830. eternal.
  831.  
  832. This declaration does not extend to the various subroutines used to form the 
  833. example programs in which the GIP subroutines reside.
  834.  
  835.